package start.designpattern.factory.abstractdemo.helper;

import lombok.extern.slf4j.Slf4j;
import start.designpattern.factory.abstractdemo.AodiCarFactory;
import start.designpattern.factory.abstractdemo.BaoMaCarFactory;
import start.designpattern.factory.abstractdemo.BenChiCarFactory;
import start.designpattern.factory.abstractdemo.CarFactory;

@Slf4j
public class Car {

    /**
     * 发动机
     */
    private Engine engine;

    /**
     * 座椅
     */
    private Seat seat;

    /**
     * 轮胎
     */
    private Tyre tyre;

    private Car() {

    }

    private static Car create(CarFactory carFactory) {

        Car car = new Car();
        car.engine = carFactory.createEngine();
        car.seat = carFactory.createSeat();
        car.tyre = carFactory.createTyre();

        log.info("豪华超跑创建完毕，发动机[{}]，轮胎[{}]，座椅[{}]", car.engine.getName(), car.tyre.getName(), car.seat.getName());

        return car;
    }


    public Engine getEngine() {
        return engine;
    }

    public void setEngine(Engine engine) {
        this.engine = engine;
    }

    public Seat getSeat() {
        return seat;
    }

    public void setSeat(Seat seat) {
        this.seat = seat;
    }

    public Tyre getTyre() {
        return tyre;
    }

    public void setTyre(Tyre tyre) {
        this.tyre = tyre;
    }


    public static void main(String[] args) {


        Car.create(new BenChiCarFactory());

        Car.create(new AodiCarFactory());

        Car.create(new BaoMaCarFactory());
    }
}
